package com.hangzhou.welbeing.welbeinginstrument.fragement;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.activity.SearchActivity;
import com.hangzhou.welbeing.welbeinginstrument.adapter.ShortPagerAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 时间 2017 年 08 月 21.
 * 作者 Administrator  刘传华
 * 公司 杭州惟君医疗科技有限公司
 * 包名 com.hangzhou.welbeing.pregnant.welbeing_pregnant.fragement
 * 工程名 welbeing_pregnant
 *
 * @desc 圈子Fragment
 */
public class CircleFragment extends Fragment implements View.OnClickListener {
    private static final String TAG = "CircleFragment";
    @Bind(R.id.activity_circle_tb)
    TabLayout activityCircleTb;
    @Bind(R.id.activity_circle_tv_search)
    ImageView activityCircleIvComments03;
    @Bind(R.id.activity_circle_viewpager)
    ViewPager activityCircleViewpager;
    private Context mcontext;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mcontext, R.layout.activity_circle, null);
        ButterKnife.bind(this, view);
        ShortPagerAdapter adapter = new ShortPagerAdapter(getChildFragmentManager());
        activityCircleViewpager.setAdapter(adapter);
         activityCircleTb.setupWithViewPager(activityCircleViewpager);
        activityCircleViewpager.setCurrentItem(0);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        activityCircleViewpager.setCurrentItem(0);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.activity_circle_tv_search:
                Intent intent2 = new Intent(getContext(), SearchActivity.class);
                startActivity(intent2);
                break;
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
